package StudyCode.summary.myfile;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.FileTime;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class UpdateTimeAttribute {
	public static void main(String[] args) {

		Path path = Paths.get("E:\\迅雷下载", "test1.txt");

		long time = System.currentTimeMillis();
		FileTime fileTime = FileTime.fromMillis(time);
		try {
			Files.getFileAttributeView(path, BasicFileAttributeView.class).setTimes(fileTime, fileTime, fileTime);
			System.out.println("文件最后修改时间、访问时间以及创建时间更新为当前时间成功！");
		} catch (IOException e) {
			System.err.println(e);
		}

	}
}
